
package com.rjet.view_demo1;

import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;

import razerdp.basepopup.BasePopupWindow;

public class MainActivity extends AppCompatActivity {

    public static final String TAG = "czy";

    ArrayList<DemoEntity> demoEntities = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        //container 从android.R系统中获取
        ViewGroup container = (ViewGroup)findViewById(android.R.id.content);
        TextView v = (TextView)findViewById(R.id.click);


        v.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Log.d(TAG, "onClick: " + v.getTag());

                DemoPopup basePopupWindow = new DemoPopup(getApplicationContext());
                basePopupWindow.showPopupWindow();

                basePopupWindow.setCustomOperationListener(new DemoPopup.CustomOperationListener() {
                    @Override
                    public void dismiss() {
                        basePopupWindow.dismiss();
                    }
                });
//                View popView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.pop_view, null);
//                LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
//                        ViewGroup.LayoutParams.MATCH_PARENT,
//                        ViewGroup.LayoutParams.MATCH_PARENT
//                );
//                layoutParams.gravity = Gravity.CENTER; //居中
//                popView.setLayoutParams(layoutParams);
//                container.addView(popView);
//
////                popView.setVisibility(View.VISIBLE);
//
//                popView.findViewById(R.id.pop_view_container).setOnClickListener(new View.OnClickListener() {
//                    @Override
//                    public void onClick(View v) {
//
////                        popView.setVisibility(View.GONE);
//                        container.removeView(popView);
//                    }
//                });
            }
        });
    }
}
